package com.fqgj.sentry.policy.dao;

import com.fqgj.common.base.BaseMapper;
import com.fqgj.sentry.policy.entity.PcRuleEntity;

import java.util.List;

/**
 * User: yujianfu
 * Date: 2017-07-12
 * Time: 09:37:58.147
 */

public interface PcRuleDao extends BaseMapper<PcRuleEntity> {
    /**
     * 根据 编号查询  倒序排列
     *
     * @param code
     * @return
     */
    List<PcRuleEntity> findRuleListByCode(String code);


    List<PcRuleEntity> selectListByPolicyIds(List<Long>  policyIds);

    /**
     * 根据策略id 查询策略规则表
     *
     * @param policyId
     * @return
     */
    List<PcRuleEntity> selectListByPolicyId(Long policyId, Integer active,Integer ruleType);

    /**
     * @param policyId
     * @return
     */
    List<PcRuleEntity> findActiveRuleListByPolicyId(Long policyId, Integer ruleType);


    /**
     * 规则 删除
     *
     * @param ruleId
     * @return
     */
    Integer deleteRuleById(Long ruleId);


    void deleteByRuleIds(List<Long> ruleIds);

    /**
     * 激活状态 更新
     *
     * @param ruleId
     * @return
     */
    Integer updateRuleActive(Long ruleId, Integer activeStatus);

    /**
     * 查询 最大编码
     *
     * @return
     */
    Integer findMaxCode(Long policySetsId);
    /**
     * 查询 最大sort
     *
     * @return
     */
    Integer findMaxSort(Long policySetsId);
    /**
     * 根据 商户ID  执行者id 查询
     *
     * @retu
     */
    List<PcRuleEntity> findActiveByPolicySetsIdAndExecutorId(Long policySetsId, Long executorId);

    /**
     * 根据策略id  查询公用规则
     *
     * @param policyId
     * @return
     */
    PcRuleEntity findCommonRuleByPolicy(Long policyId);

    /**
     * 更新 规则排序
     *
     * @param ruleId
     * @param sort
     * @return
     */
    Boolean updateRuleSort(Long ruleId, Integer sort);

}